#ifndef PRIORITYLIST_H
#define PRIORITYLIST_H

#include "Prerequisites.hpp"
#include <QDebug>

/** Custom priority list.
@remarks
Vector of (int, vector) where int is priority and vector is element vector;
*/
class PriorityList
{
protected:
    typedef vector<int>::type intListBase;
    typedef vector<int>::iterator intListIterator;
    struct element {
        int priority;
        intListBase elements;
    };
    typedef vector<element>::type elementListBase;
    typedef vector<element>::iterator elementListIterator;
public:
    PriorityList(int rMaxPriority, int rMinPriority);
    ~PriorityList();

    /**
     * @brief add element to priority list;
     * @param rPriority - priority;
     * @param rId - element id;
     */
    void add(int rPriority, int rId);
    /**
     * @brief remove element from priority list;
     * @param rId - element id;
     */
    void remove(int rId);
    /**
     * @brief pop - returns element id with highest priority and DELETES it;
     */
    int pop(void);
    /**
     * @brief top - returns element id with highest priority WITHOUT DELETING IT;
     */
    int top(void);
    /**
     * @brief size - returns the count of ALL elements;
     */
    int size(void);

    void printPriorities(void);
    void printElements(void);
private:
    const int maxPriority;
    const int minPriority;
    elementListBase list;
};

#endif // PRIORITYLIST_H
